﻿-- Function: tepuy.schema(character varying)

-- DROP FUNCTION tepuy.schema(character varying);

CREATE OR REPLACE FUNCTION tepuy.schema(character varying)
  RETURNS boolean AS
$BODY$
-- Copyright © 2010 Riztan Gutierrez <riztan at gmail dot com>
-- Esto es parte de: proyecto tepuy.
-- Este programa es Software Libre conforme a la GPL Version 3 o posterior.
-- http://www.gnu.org/licenses/
DECLARE
    cschema varchar;
BEGIN
   select schema_name into cschema from information_schema.schemata
      where schema_name=$1;

   if not found then
      RETURN false;
   end if;

   RETURN true;

END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE
  COST 100;
ALTER FUNCTION tepuy.schema(character varying) OWNER TO postgres;
COMMENT ON FUNCTION tepuy.schema(character varying) IS 'retorna verdadero si el esquema existe';
